import { ApiProperty, OmitType, PartialType, PickType } from '@nestjs/swagger';
import { IsInt, IsString } from 'class-validator';

export class DepartmentDto {
  @IsInt()
  @ApiProperty({ type: Number, description: 'id' })
  readonly id: number;

  @IsInt()
  @ApiProperty({ type: Number, description: '父id' })
  public parent_id: number;

  @IsString()
  @ApiProperty({ type: String, description: '部门名称' })
  public dept_name: string;

  @IsInt()
  @ApiProperty({ type: Number, description: '显示顺序' })
  public sort: number;

  @IsString()
  @ApiProperty({ type: String, description: '部门状态' })
  public status: string;

  @IsString()
  @ApiProperty({
    type: String,
    description: '删除标志（0代表存在 1代表删除）',
    default: '0',
  })
  readonly is_delete: string;

  @IsString()
  @ApiProperty({
    type: String,
    description: '备注',
    default: null,
  })
  readonly remark: string;

  @ApiProperty({ type: Date, description: '创建时间', default: null })
  readonly created_date: Date;

  @IsString()
  @ApiProperty({
    type: String,
    description: '创建人',
    default: null,
  })
  readonly created_by: string;

  @ApiProperty({ type: Date, description: '更新时间', default: null })
  readonly updated_date: Date;

  @IsString()
  @ApiProperty({
    type: String,
    description: '更新人',
    default: null,
  })
  readonly updated_by: string;

  @ApiProperty({
    type: Object,
    description: '用户',
    default: null,
  })
  users: any;
}

export class CreateDepartmentDto extends PartialType(
  OmitType(DepartmentDto, ['id']),
) {}

export class DepartmentObj extends PickType(DepartmentDto, ['id'] as const) {}

export class UpdateDepartmentDto extends PartialType(
  OmitType(DepartmentDto, ['created_date', 'updated_date']),
) {}
